package com.love.travel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.love.common.log.annotation.Log;
import com.love.common.log.enums.BusinessType;
import com.love.common.security.annotation.RequiresPermissions;
import com.love.travel.domain.TravelProductTag;
import com.love.travel.service.ITravelProductTagService;
import com.love.common.core.web.controller.BaseController;
import com.love.common.core.web.domain.AjaxResult;
import com.love.common.core.utils.poi.ExcelUtil;
import com.love.common.core.web.page.TableDataInfo;

/**
 * 产品-标签关联Controller
 * 
 * @author love
 * @date 2025-10-23
 */
@RestController
@RequestMapping("/productTag")
public class TravelProductTagController extends BaseController
{
    @Autowired
    private ITravelProductTagService travelProductTagService;

    /**
     * 查询产品-标签关联列表
     */
    @RequiresPermissions("travel:productTag:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelProductTag travelProductTag)
    {
        startPage();
        List<TravelProductTag> list = travelProductTagService.selectTravelProductTagList(travelProductTag);
        return getDataTable(list);
    }

    /**
     * 导出产品-标签关联列表
     */
    @RequiresPermissions("travel:productTag:export")
    @Log(title = "产品-标签关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelProductTag travelProductTag)
    {
        List<TravelProductTag> list = travelProductTagService.selectTravelProductTagList(travelProductTag);
        ExcelUtil<TravelProductTag> util = new ExcelUtil<TravelProductTag>(TravelProductTag.class);
        util.exportExcel(response, list, "产品-标签关联数据");
    }

    /**
     * 获取产品-标签关联详细信息
     */
    @RequiresPermissions("travel:productTag:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(travelProductTagService.selectTravelProductTagById(id));
    }

    /**
     * 新增产品-标签关联
     */
    @RequiresPermissions("travel:productTag:add")
    @Log(title = "产品-标签关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelProductTag travelProductTag)
    {
        return toAjax(travelProductTagService.insertTravelProductTag(travelProductTag));
    }

    /**
     * 修改产品-标签关联
     */
    @RequiresPermissions("travel:productTag:edit")
    @Log(title = "产品-标签关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelProductTag travelProductTag)
    {
        return toAjax(travelProductTagService.updateTravelProductTag(travelProductTag));
    }

    /**
     * 删除产品-标签关联
     */
    @RequiresPermissions("travel:productTag:remove")
    @Log(title = "产品-标签关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(travelProductTagService.deleteTravelProductTagByIds(ids));
    }
}
